{% extends "base.html" %}

{% block title %}Problems{% endblock %}

{% from "_helpers.html" import render_field %}
{% from "_helpers.html" import paginator %}
{% block body %}
<div class="row">
    <div class="col-md-12">
      <div id="problem-filter" class="well">
        <form class="form-inline" method="GET">
            {{ render_field(filter_form.opsysreleases, class="multiselect") }}
            {{ render_field(filter_form.component_names, placeholder="Components", class="component-names") }}
            {{ render_field(filter_form.associate, class="multiselect-filtered-dynamic hidden") }}
            {{ render_field(filter_form.type, class="multiselect") }}
            {{ render_field(filter_form.daterange, class="form-control daterange") }}
            {% if filter_form.arch.data or filter_form.exclude_taintflags.data
                  or filter_form.function_names.data or filter_form.binary_names.data
                  or filter_form.source_file_names.data
                  or filter_form.since_version.data or filter_form.since_release.data
                  or filter_form.to_version.data or filter_form.to_release.data 
                  or filter_form.probable_fix_osrs.data
                  or filter_form.bug_filter.data != "None" %}
              <div id="advanced-filters" class="separated">
            {% else %} 
              <a href="#" id="show-advanced-filters" class="btn btn-default"><i class="fa fa-caret-right"></i> Advanced filters</a>
              <div id="advanced-filters" class="separated hide">
            {% endif %}
              <div>
                {{ render_field(filter_form.arch, class="multiselect") }}
                {{ render_field(filter_form.exclude_taintflags, class="multiselect") }}
                {{ render_field(filter_form.probable_fix_osrs, class="multiselect") }}
                {{ render_field(filter_form.bug_filter, class="multiselect") }}
              </div>
              <div>
                {{ render_field(filter_form.function_names, placeholder="Functions") }}
                {{ render_field(filter_form.binary_names, placeholder="Binaries/Modules") }}
                {{ render_field(filter_form.source_file_names, placeholder="Source files") }}
                <p class="text-muted">Comma acts as OR, you can use % as a wildcard, at least one backtrace where all three fields are satisfied must exist to show the problem</p>
              </div>
              <div>
                {{ render_field(filter_form.since_version, placeholder="Since version") }}
                {{ render_field(filter_form.since_release, placeholder="Since release") }}
                {{ render_field(filter_form.to_version, placeholder="To version") }}
                {{ render_field(filter_form.to_release, placeholder="To release") }}
                <p class="text-muted">Version range
                    <a role="button" data-toggle="tooltip" data-html="true" title="To search in bugs
                    for component foo within versions <b>1.1.1-1</b> and <b>2.0.0-3</b>, set<br/>
                    <b>Since version</b> to <b>1.1.1</b></br><b>Since release</b> to <b>1</b><br/>
                    <b>To version</b> to <b>2.0.0</b><br/><b>To release</b> to <b>3</b>">
                        <span class="fa fa-lg fa-info-circle">
                    </a>
                </p>
              </div>
              <div style="margin-bottom: 5px; padding: inherit">
                  <label for="solution" style="margin-right: 10px; display: inline";>Solution</label>
                  {{ filter_form.solution }}
              </div>
            </div>
            <button class="btn btn-primary" type="submit">Query</button>
        </form>
      </div>
      <div id="problem-list">
        <table class="table table-striped table-bordered table-condensed">
          <thead>
            <tr>
              <th>ID</th>
              <th>Component</th>
              <th>Crash function</th>
              <th>State</th>
              <th>External bugs</th>
              <th class="cursor-help" title="Version of the oldest affected package since which the problem stopped occuring in the given release.">Probably fixed</th>
              <th>Count</th>
            </tr>
          </thead>
          {% if list_table_rows %}
            {{list_table_rows|safe}}
          {% else %}
            {% include "problems/list_table_rows.html" with context %}
          {% endif %}
        </table>
      </div>
    </div>
    <div class="col-md-12">
        {{ paginator(pagination, problem_count) }}
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function(){
        $('a[data-toggle=tooltip]').tooltip();
    });
</script>
{% endblock %}
